import {
  BannerCreateDto,
  BannerFindDto,
  BannerListDto,
  BannerQueryDto,
  BannerRemoveDto,
  BannerUpdateDto,
} from '@/dtos';
import { BannerService } from '@/services/banner.service';
import { ok } from '@/utils';
import { Body, Controller, Delete, Patch, Post, Query } from '@nestjs/common';
import { BaseController } from './base.controller';

@Controller('banner')
export class BannerController extends BaseController {
  constructor(private readonly bannerService: BannerService) {
    super();
  }

  @Post('list')
  async getList(@Body() dto: BannerListDto) {
    return ok(await this.bannerService.getList(dto));
  }

  @Post('admin/query')
  async query(@Body() dto: BannerQueryDto) {
    return ok(await this.bannerService.query(dto));
  }

  @Post('admin/find')
  async find(@Body() dto: BannerFindDto) {
    return ok(await this.bannerService.findOne(dto.where, dto.select));
  }

  @Post('admin/create')
  async create(@Body() dto: BannerCreateDto) {
    return ok(await this.bannerService.create(dto.data));
  }

  @Patch('admin/update')
  async update(@Body() dto: BannerUpdateDto) {
    return ok(await this.bannerService.update(dto));
  }

  @Delete('admin/remove')
  async remove(@Query() dto: BannerRemoveDto) {
    return ok(await this.bannerService.remove(dto));
  }
}
